package rs.dalao.syc.user.chat.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

@Component
public class BeanUtils {

  private static ApplicationContext applicationContext;
  
  // 设置ApplicationContext
  @Autowired
  public void setApplicationContext(ApplicationContext context) {
    applicationContext = context;
  }
  
  // 获取Bean
  public static <T> T getBean(Class<T> clazz) {
    return applicationContext.getBean(clazz);
  }
}
